home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: in2.uu.net!iglou!iglou2!quare
- From: quare@iglou2.iglou.com (quare)
- Subject: Re: strange problem with strcpy()
- X-Nntp-Posting-Host: iglou2
- Message-ID: <DKGz2u.8rs@iglou.com>
- Sender: news@iglou.com (News Administrator)
- Organization: IgLou Internet Services (1-800-436-4456)
- X-Newsreader: TIN [version 1.2 PL2]
- References: <DKFsII.FyJ@iglou.com> <30e62ceb.8255139@ixnews1.ix.netcom.com>
- Date: Sun, 31 Dec 1995 21:16:06 GMT
-
- n4jvp (n4jvp@ix.netcom.com) wrote:
-
- > Would the problem be that pointer->name is a char * that is
- > initialized but not defined? When memory is allocated for data member
- > char * name (\0) that is all the memory you have for that data member.
- > Doing a strcpy() as you describe might make * name appear to be test.c
- > but in memory there is only room for one character, the terminating
- > null.
- > Thats my best guess without seeing some code...
-
- Don't think so. Basically I allocate sizeof(struct find_t) *
- number_of_files_in_cwd. The find_t structure (as defined by Ms-dog)
- contains (for filename storage) char name[14]; (8 chars for filename, one
- for a 'dot' [.] and 3 for the extension.. and of course, 1 for the null).
-
- I am dynamically realloc()'ing more space as the need arises (i start out
- with space for 50 files). If more than 50 files are read in, I realloc()
- for sizeof(struct find_t) * (50 + current_file_count). The realloc call
- never fails (at least not while I'm debugging it). I will post the code
- if anyone thinks they might know the problem (it's less than 100 lines).
-
- --
- !quare
-
-